package vip.mengqin.diandezhun.manager;

import android.content.Context;

import com.android.baselibrary.interface_.OkHttpCallBack;
import com.android.commcount.request.Recharge_Price_Item_Request;
import com.lzy.okgo.model.HttpMethod;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import vip.mengqin.diandezhun.constant.ApiConstants;

public class API_Manager {

    //获取服务器时间
    public static void timestamp(Context context, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.timestamp;
        Map<String, Object> bodyParames = new HashMap<>();
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.GET, url, null, null, bodyParames, callBack);
    }

    //登录
    public static void login(Context context, String phone, String code, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.login;
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("code", code);
        bodyParames.put("mobile", phone);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, null, null, bodyParames, callBack);
    }

    //发验证码
    public static void sendcode(Context context, String phone, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.sendcode;
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("mobile", phone);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, null, null, bodyParames, callBack);
    }

    //一键登录
    public static void login_onekey(Context context, String loginToken, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.login_onekey;
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("loginToken", loginToken);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, null, null, bodyParames, callBack);
    }

    //用户信息
    public static void getUserInfo(Context context, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.userinfo;
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.GET, url, null, null, null, callBack);
    }

    //banner
    public static void getBannerList(Context context, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.banners;
        Map<String, Object> bodyParames = new HashMap<>();
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.GET, url, null, null, bodyParames, callBack);
    }

    //充值面值列表
    public static void recharge(Context context, int templateId, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.recharge_value;
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("templateId", templateId);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.GET, url, bodyParames, null, null, callBack);
    }

    //注销
    public static void logoff(Context context, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.logoff;
        Map<String, Object> bodyParames = new HashMap<>();
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, bodyParames, null, null, callBack);
    }

    //实时获取当前已添加联系人获取当前的总价格和折扣
    public static void recharge_price(Context context, int templateId, List<Recharge_Price_Item_Request> items, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.recharge_price;
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("templateId", templateId);
        bodyParames.put("items", items);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, null, null, bodyParames, callBack);
    }

    //充值统一下单
    public static void recharge_recharge(Context context, int templateId, List<Recharge_Price_Item_Request> items, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.recharge_recharge;
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("templateId", templateId);
        bodyParames.put("items", items);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, null, null, bodyParames, callBack);
    }

    //获取下单信息
    public static void order_payinfo(Context context, int orderId, String payment, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.order_pay;
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("orderId", orderId);
        bodyParames.put("payment", payment);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, null, null, bodyParames, callBack);
    }

    //下单结果
    public static void order_pay_result(Context context, int orderId,  OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.order_pay_result+ "/"+ orderId;
//        Map<String, Object> bodyParames = new HashMap<>();
//        bodyParames.put("orderId", orderId);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.GET, url, null, null, null, callBack);
    }



}
